import 'package:flutter/services.dart';
import 'dart:ui' as ui;
class AssetUtils{

  ///加载asset资源
  ///   @Example
  ///   AssetUtils.loadAsset("static/datas/country_code.json").then((countryCode) {
  ///        var jsonRes = json.decode(countryCode);
  ///        _handleList(jsonRes['data']);
  ///    });
  static Future<String> loadAsset(String asset) async {
    return await rootBundle.loadString(asset);
  }

  static Future<ui.Image> loadImage(String asset,int width,int height) async {
    ByteData data = await rootBundle.load(asset);
    ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),targetWidth: width,targetHeight: height);
    ui.FrameInfo fi = await codec.getNextFrame();
    return fi.image;
  }
}